<?php
session_start();   
include "application.php";
application_start ();

//Option Explicit;
 
//dim $strChatBody, $strUsers;
//dim $intChatTimeout;
//dim $binChange, $strChange;
//dim $arrUsers, $i;

$intChatTimeout = $_GET["chatTimeout"];//Request("chatTimeout");

 
if ($intChatTimeout != $_APP["intChatTimeout"]) {
//	Application.Lock;
//	Application("intChatTimeout") = $intChatTimeout;
//	Application.Unlock;

	$_APP["intChatTimeout"]= $intChatTimeout;
}

//$_SESSION["strChatBody"] = ""; 
$strUsers = @$_APP["strUsers"]; //Application("strUsers");


$arrUsers = Array();
$arrUsers = split('\|',$strUsers); //"|"
 
$strChange = "";
 
for ($i=0; $i < count($arrUsers); $i++) {  // Cycle through the list of users to see who's timed out
	//if (Not Application("Timeout_".$arrUsers[$i]) > date("n/j/Y g:i:s A") ) {
	if (@$_APP["Timeout_".$arrUsers[$i]] > date("n/j/Y g:i:s A") ) {		
		$strChange = $strChange.'<BR><FONT COLOR="#BB0000"><B>'.$arrUsers[$i]." has been logged out due to inactivity</B></FONT>"."\n";
		$strUsers = str_replace($arrUsers[$i]."|","",$strUsers);
		$binChange = True;
	}
}
 
if ($binChange == True) {  // If someone has timed out, remove them.
	//Application.Lock;
	//Application("strUsers") = $strUsers;
	//Application.UnLock;
	$strChatBody = $strChatBody . $strChange;
}
 
$strChatBody = @$_APP["strChatBody"];
application_end ();

?>
<HTML>
<HEAD>
<!-- Previous version removed due to refresh problems
<META HTTP-EQUIV="REFRESH" CONTENT="3;URL=body.php">-->
<META HTTP-EQUIV=refresh content="3">
	<TITLE>Chat Room App</TITLE>
<? include "style.php"; ?>
</HEAD>
<BODY BGCOLOR="#FFFFFF" onLoad="window.scrollTo(0,700)">
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 HEIGHT="100%" WIDTH="100%">
<TR><TD VALIGN="TOP">
<?
echo $strChatBody;
 
//Response.Write intChatTimeout & Application("Timeout_Peter")  // Debugging
?>
</TD></TR></TABLE>
</BODY>
</HTML>

